import 'package:aihu_getx_app/app/modules/commons/commons.dart';
import 'package:aihu_getx_app/app/routes/app_pages.dart';
import 'package:aihu_getx_app/utils/cache_keys.dart';
import 'package:aihu_getx_app/utils/constants.dart';
import 'package:common_utils/common_utils.dart';
import 'package:sp_util/sp_util.dart';

class LoginInterceptChain {
  // 是否现已登录
  static bool isLogin() {
    var loginInfo = Commons.getLoginResModel();
    String? token = loginInfo?.accessToken;
    return !TextUtil.isEmpty(token);
  }

  static String logout() {
    var config = Commons.getCurrentClientConfig();
    if (config.idx.type == ClientType.d.type) {
      SpUtil.remove(CacheKeys.adminLoginInfo);
      return Routes.adminLogin;
    }
    SpUtil.remove(CacheKeys.userLoginInfo);
    return Routes.userLogin;
  }
}
